<!--
 /**
 * Author: hongChengHao
 * Date: 2022-07-28 11:40
 * Desc: message 我的消息
 */
-->
<template>
  <yy-page class="message">
    <view class="message__content">
      <yy-list :list="listData" :loading="listLoading" :finished="listFinished" empty-type="message">
        <my-message v-for="item in listData" :key="item.messageId" :obj="item" @after-save="listRefresh"></my-message>
      </yy-list>
    </view>
  </yy-page>
</template>
<script>
  import MyMessage from './components/Message.vue'
  import listMixins from '@/mixins/listMixins'
  import { deDupArray } from '@/utils'
  export default {
    components: { MyMessage },
    mixins: [listMixins],
    name: 'message',
    data() {
      return {}
    },
    onShow() {
      this.listLoad()
    },
    methods: {
      onloadList() {
        const query = {
          ...this.search,
          ...this.pageInfo
        }
        return uni.$api.message.getSystemMsg(query).then((res) => {
          if (this.isLoading) {
            // 是下啦刷新 清空
            this.listData = []
          }
          const listData = [...this.listData, ...res.list]
          this.listData = deDupArray(listData, 'messageId')
          return res
        })
      },
      onPullDownRefresh() {
        this.listRefresh()
      },
      onReachBottom() {
        this.listLoad()
      }
    }
  }
</script>
